package com.qiaoas.springbootjdbctemplate.Controller;


import com.qiaoas.springbootjdbctemplate.Bean.User;
import com.qiaoas.springbootjdbctemplate.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("insert")
    public int insert(){
        User user = new User();
        user.setNo(12);
        user.setAge(88);
        user.setName("111");
        return this.userService.insert(user);
    }

    @RequestMapping("update")
    public int update(){
        User user = new User();
        user.setNo(12);
        user.setAge(881);
        user.setName("1231");
        return this.userService.update(user);
    }

    @GetMapping("delete")
    public int delete(){
        User user = new User();
        user.setNo(11);
        return this.userService.delete(user);
    }

    @GetMapping("select")
    public User select(){
        return this.userService.selete(11);
    }

    @GetMapping("userList")
    public List<Map<String, Object>> userList(){
        return this.userService.userList();
    }


}
